<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Compiling and Linking on Windows</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="kvaser.gif"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('page_user_guide_build_compiling_linking_windows.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Compiling and Linking on Windows </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#section_user_guide_build_compiling_linking_windows">Compiling and Linking Your Code on Windows</a></li>
<li class="level1"><a href="#section_user_guide_build_installation_deploy">Deploying Your Application</a></li>
<li class="level1"><a href="#section_user_guide_intro_redistributable">Redistributable Files in CANlib SDK</a></li>
</ul>
</div>
<div class="textblock"><h1><a class="anchor" id="section_user_guide_build_compiling_linking_windows"></a>
Compiling and Linking Your Code on Windows</h1>
<p>CANlib supports 32- and 64-bit programs.</p>
<h2>canXXX and kvXXX APIs</h2>
<p>The APIs named <b>canXXX</b> and <b>kvXXX</b> are defined in canlib32.dll.</p>
<p><b>C, C++ (Microsoft Visual Studio, Embarcadero RAD Studio)</b><br />
</p><ul>
<li>Include <a class="el" href="canlib_8h.html">canlib.h</a>.</li>
<li>Link with the import library canlib32.lib.</li>
</ul>
<p>Embarcadero and Microsoft have different formats for the import libraries - be sure to pick the correct one; CANlib SDK is shipped with both versions. For Microsoft compilers, it is worth noting that the import library shipped with CANlib SDK is compatible with <b>Visual C++ 5.0 or later</b>.</p>
<p>We haven't tested it ourselves, but we hear that people have had success with <b>CodeWarrior</b>, <b>Watcom</b> and <b>gcc</b> compilers as well.</p>
<p><b>Embarcadero Delphi (2.0 or later)</b><br />
 Use the CAN unit if you want to use the CANlib API directly; this means:</p><ul>
<li>Put it in a uses clause in your program.</li>
<li>Include it in the project.</li>
</ul>
<p>The unit will dynamically load (with a call to the Windows API function <code>LoadLibrary</code>) the appropriate DLL, which is canlib32.dll for 32-bit programs. There is also a VCL component, <code>TCanChannelEx</code>, that may make your life a little bit easier.</p>
<p><b>Microsoft Visual Basic, 5.0 or 6.0</b><br />
 Include canlib32.bas in your project. We have included a sample program that is tested with VB5. VB4 users should be able to use the program code (in the .FRM file) by some cutting-and-pasting.</p>
<p><b>Microsoft C#, or Microsoft Visual Basic .NET</b><br />
 See the C# sample in SAMPLES.</p>
<p><b>Other languages</b><br />
 canlib32.dll is a standard Windows DLL, and all entry points are using the Windows stdcall calling convention. This means it should be callable from any other language. Please refer to your language manual to obtain information on how to link to a standard Windows DLL.</p>
<h2>Database API - kvaDbXXX</h2>
<p>The APIs named <b>kvaDbXXX</b> are defined in kvaDbLib.dll.</p>
<p>C/C++ code that uses these APIs should</p><ul>
<li>Include <a class="el" href="kva_db_lib_8h.html">kvaDbLib.h</a></li>
<li>Link with the import library kvaDbLib.lib</li>
</ul>
<h2>LIN API - linXXX</h2>
<p>The APIs named <b>linXXX</b> are defined in linlib.dll.</p>
<p>C/C++ code that uses these APIs should</p><ul>
<li>Include <a class="el" href="linlib_8h.html">linlib.h</a>.</li>
<li>Link with the import library linlib.lib</li>
</ul>
<h2>J1587 API - j1587XXX</h2>
<p>The APIs named <b>j1587XXX</b> are defined in j1587lib.dll.</p>
<p>C/C++ code that uses these APIs should</p><ul>
<li>Include j1587lib.h.</li>
<li>Link with the import library j1587.lib</li>
</ul>
<h2>Library formats</h2>
<p>Borland and Microsoft have different formats for the import libraries - be sure to pick the correct one; CANlib SDK is shipped with both versions. For Microsoft compilers, it is worth noting that the import library shipped with CANlib SDK is compatible with <b>Visual C++ 5.0 or later</b>.</p>
<div> <h2>DLL dependencies</h2>
</div><div> Lists all .Net Standard wrappers and specifies the dependencies and runtime version for .NET development.</div><div> <h3>32-bit DLL dependencies</h3>
</div><div> <table border="1">
<tr>
<th align="left">DLL </th><th align="left">.Net Standard</th><th align="left">Dependencies </th></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.CanLib.dll </td><td>v2.0 </td><td>Bin\canlib32.dll </td></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.KvaDbLib.dll </td><td>v2.0 </td><td>Bin\kvadblib.dll </td></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.KvlcLib.dll </td><td>v2.0 </td><td>Bin\kvadblib.dll,<br />
Bin\kvlclib.dll,<br />
Bin\kvmlib.dll </td></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.KvmLib.dll </td><td>v2.0 </td><td>Bin\kvmLib.dll </td></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.KvrLib.dll </td><td>v2.0 </td><td>Bin\kvrlib.dll </td></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.LinLib.dll </td><td>v2.0 </td><td>Bin\linlib.dll </td></tr>
<tr>
<td>dotnet\win32\netstandard2.0\Kvaser.MemoLibXML.dll </td><td>v2.0 </td><td><p class="starttd">Bin\kvaMemoLibXML.dll</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Bin\kvlclib.dll </td><td>- </td><td><p class="starttd">Bin\kvadblib.dll,<br />
 Bin\libmat.dll,<br />
 Bin\libmx.dll,<br />
 Bin\libut.dll<br />
  </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Bin\kvmlib.dll </td><td>- </td><td><p class="starttd">Bin\kvamemolib.dll, Bin\kvaMemoLib0600.dll, Bin\kvaMemoLib0700.dll</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Bin\coti.dll<br />
 Bin\j1587lib.dll<br />
 Bin\j2534\kvj2534c.dll<br />
 Bin\j2534\kvj2534i.dll<br />
 Bin\j2534api.dll<br />
 Bin\linlib.dll<br />
 Bin\rp1210\kv121032.dll  </td><td>- </td><td><p class="starttd">Bin\canlib32.dll</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>Bin\kvrlib.dll </td><td>- </td><td>Bin\canlib32.dll,<br />
 Bin\irisdll.dll,<br />
 Bin\irisflash.dll,<br />
 Bin\libxml2.dll<b>(statically linked with zlib, iconv)</b> </td></tr>
</table>
</div><div> <h3>64-bit DLL dependencies</h3>
</div><div> <table border="1">
<tr>
<th align="left">DLL </th><th align="left">.Net Standard</th><th align="left">Dependencies </th></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.CanLib.dll </td><td>v2.0 </td><td>bin_x64\canlib32.dll </td></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.KvaDbLib.dll </td><td>v2.0 </td><td>bin_x64\kvadblib.dll </td></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.KvlcLib.dll </td><td>v2.0 </td><td>bin_x64\kvadblib.dll,<br />
bin_x64\kvlclib.dll,<br />
bin_x64\kvmlib.dll </td></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.KvmLib.dll </td><td>v2.0 </td><td>bin_x64\kvmLib.dll </td></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.KvrLib.dll </td><td>v2.0 </td><td>bin_x64\kvrlib.dll </td></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.LinLib.dll </td><td>v2.0 </td><td>bin_x64\linlib.dll </td></tr>
<tr>
<td>dotnet\x64\netstandard2.0\Kvaser.MemoLibXML.dll </td><td>v2.0 </td><td><p class="starttd">Bin_x64\kvaMemoLibXML.dll</p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>bin_x64\kvlclib.dll </td><td>- </td><td>bin_x64\kvadblib.dll,<br />
 Matlab dll:s libmat.dll, libmx.dll, libut.dll and their dependencies (located in the bin_x64 directory)<br />
 The Matlab dll:s require the Visual C++ Redistributable Package for Visual Studio 2013 (<a href="https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784">https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784</a>) to be installed.   </td></tr>
<tr>
<td>bin_x64\kvmlib.dll </td><td>- </td><td>bin_x64\kvamemolib.dll, bin_x64\kvaMemoLib0600.dll, bin_x64\kvaMemoLib0700.dll </td></tr>
<tr>
<td>bin_x64\j1587lib.dll<br />
 bin_x64\j2534api.dll<br />
 bin_x64\linlib.dll  </td><td>- </td><td><p class="starttd">bin_x64\canlib32.dll </p>
<p class="endtd"></p>
</td></tr>
<tr>
<td>bin_x64\kvrlib.dll </td><td>- </td><td><p class="starttd">bin_x64\canlib32.dll,<br />
 bin_x64\irisdll.dll,<br />
 bin_x64\irisflash.dll,<br />
 bin_x64\libxml2.dll<b>(statically linked with zlib, iconv)</b>  </p>
<p class="endtd"></p>
</td></tr>
</table>
</div><h1><a class="anchor" id="section_user_guide_build_installation_deploy"></a>
Deploying Your Application</h1>
<p>As an application programmer, you may want to distribute canlib32.dll together with your application. If you choose to do so, you should place it in the application's directory. In this way you will not break any other applications on the computer.</p>
<p>If you install canlib32.dll on the target system, and the rest of the device drivers are not installed, any call you make to canlib32.dll will return an error code. You should be prepared for this situation and handle the error code in a constructive way in your application. Another situation could be that the deployed application is using a new canlib32.dll function, as this also would require an update of the drivers it’s important to implement error handling in such a way that the application will inform the user to update their drivers.</p>
<p>A version mismatch between canlib32.dll and drivers will return the error code: <a class="el" href="canstat_8h.html#a52b5e5c71832b0bd3c6a5b1fd48583e7aee571ea29d786d483d1d3ea9f70d6753">canERR_DYNALIB</a>, please see <a class="el" href="page_user_guide_intro.html#section_user_guide_canstatus">Error checking</a> for further reading about error handling.</p>
<p>It is also possible to programmatically install the required device driver without user intervention.</p>
<h1><a class="anchor" id="section_user_guide_intro_redistributable"></a>
Redistributable Files in CANlib SDK</h1>
<p>The following files included in the CANLIB SDK may be redistributed with your application, provided they are only used together with genuine Kvaser hardware.</p>
<ul>
<li>canlib32.dll<br />
 API for CAN applications.</li>
<li>Kvaser.CanLib.dll<br />
 API for CAN applications in the .NET environment.</li>
<li>sing32.dll<br />
 API for emulating Softing's CAN API.</li>
<li>vcand32.dll<br />
 API for emulating Vector Informatik's CAN API.</li>
<li>j1587lib.dll<br />
 J1587 API DLL (for Kvaser Linx)</li>
<li>kv121032.dll<br />
 RP1210A/B API DLL</li>
<li>kvj2534.dll, kvj2534c.dll, kvj2534i.dll<br />
 SAE J2534 API DLL</li>
<li>linlib.dll<br />
 API for LIN applications.</li>
</ul>
<p>You may use and distribute the source code found in the SAMPLES directory in your own applications without restrictions.</p>
<p>Please contact <a class="el" href="page_support.html">Kvaser Support</a> if you would like to redistribute any file not found in this list. </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="page_user_guide_build.html">Compiling and Compatibility</a></li>
    <li class="footer"> (canlib 5.38) Tue Feb 15 2022</li>
  </ul>
</div>
</body>
</html>
